<template>
  <div>
    <div class="home-box box-3-list">
      <div class="center-box1">
        <div class="box-title-1">
          <img src="@/assets/image/5.webp" alt="">
          <div class="center">
            <p>脏话系统</p>
            <p>这里可以管理脏话哦～</p>
          </div>
        </div>
        <el-button class="table" icon="el-icon-plus" type="primary" @click="addActivity">新增</el-button>
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="word" label="屏蔽文档"></el-table-column>

          <el-table-column prop="address" fixed="right" width="150" align="center" label="操作">
            <template slot-scope="scope">
              <el-button type="danger" @click="deleteActivity(scope.row)" icon="el-icon-delete" size="mini">删除</el-button>
<!--              <el-button type="primary" @click="updateActivity(scope.row)" icon="el-icon-edit" size="mini">编辑</el-button>-->
            </template>
          </el-table-column>
        </el-table>
        <div class="box-bottom">
          <el-pagination
              large
              background
              @current-change="changePages"
              layout="prev, pager, next"
              :total="total">
          </el-pagination>
        </div>
      </div>
    </div>



    <lz-footer></lz-footer>

    <el-dialog :visible.sync="dialogVisible" width="850px" :before-close="handleClose">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动标题">
          <el-input v-model="form.word"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="danger" @click="onSubmit">立即提交</el-button>
          <el-button @click="clearForm">取消提交</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import LzSubmit from "@/components/lz-submit.vue";
import {
  deleteSwearing,
  getDatEventList,
  getEventApplicationList,
  getMyEventApplicationList,
  insertActivity, insertSwearing, selectSwearing,
  updateEvent,
  updateUser,
  uploadFile
} from "@/api/apiFox";
import {parseTime} from "@/utils";

export default {
  components: {LzSubmit},
  data() {
    return {
      imageUrl:"",
      dialogVisible:false,
      isEdit:false,
      isView:false,
      total:10,
      tableData: [],
      queryParams:{
        pageNum:1,
        pageSize:10
      },
      form: {
        word:""
      },
      participationList:[]
    }
  },
  methods:{
    changePages(e){
      console.log(e)
      this.queryParams.pageNum = e
      this.getList(this.queryParams)
    },
    getList(queryParams){
      selectSwearing(queryParams).then(res=>{
        this.tableData = res.list
        this.queryParams.pageNum = res.pageNum
        this.queryParams.pageSize = res.pageSize
        this.total = res.totalCount
      }).catch(err=>{})
    },

    addActivity(){
      this.isEdit = false
      for (let key in this.form){
        this.form[key] = ""
      }
      this.imageUrl = ""
      this.dialogVisible=true
    },

    handleClose(){
      this.clearForm()
    },
    deleteActivity(item){
      deleteSwearing({id:item.id}).then(res=>{
        this.$message.success('已删除')
        this.clearForm()
      }).catch(err=>{})
    },
    clearForm(){
      for (let key in this.form){
        this.form[key] = ""
      }
      this.imageUrl = ""
      this.dialogVisible=false
      this.getList(this.queryParams)
    },
    onSubmit(){
      insertSwearing(this.form).then(res=>{
        this.$message.success('新增成功')
        this.clearForm()
      }).catch(err=>{})
    },

  },
  mounted() {
    this.getList(this.queryParams)
  }
}
</script>

<style scoped lang="scss">
.home-box {
  width: 100%;
  min-height: calc(100vh - 140px);
  background: var(--homeBgk);
  display: flex;
  justify-content: center;

  .home-center {
    width: 1200px;
    min-height: calc(100vh - 140px);
    display: flex;
    justify-content: space-between;
    //background: #fff;
    .left {
      width: 600px;
      padding-top: 20vh;
      box-sizing: border-box;

      .logo {
        margin: 10px 0;
      }

      .title {
        font-size: 36px;
        font-weight: 400;
        //text-align: center;
        color: var(--textColor);
      }

      .content {
        font-size: 14px;
        margin-top: 15px;
        color: var(--colorTip);
      }

      .btn {
        width: 100%;
        margin-top: 30px;

        a {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 150px;
          font-size: 14px;
          height: 45px;
          color: #fff;
          background: #333;
          border-radius: 10px;
        }
      }
    }

    .right {
      width: 800px;
      margin-right: -200px;
    }
  }
}

.box-nav-list {
  background: var(--navBgk);
  height: 200px !important;
  margin-bottom: -200px;

  .home0-center {
    width: 1200px;
    padding-top: 120px;
    display: flex;
    height: 200px;
    justify-content: space-between;

    .item {
      width: 300px;
      height: 300px;
      text-align: center;

      .nav-box {
        width: 100%;
        height: 120px;
        border-radius: 50%;

        img {
          width: 100px;
          height: 100px;
          object-fit: cover;
        }
      }

      .title {
        font-size: 22px;
        color: var(--textColor);
        font-weight: 600;
      }

      .box-center {
        margin-top: 15px;
        font-size: 12px;
        color: var(--colorTip);
      }
    }
  }
}

.box-3-list {
  width: 100%;
  background: var(--navBgk);
  padding-bottom: 150px;
  padding-top: 45px;

  .center-box1 {
    width: 1200px;

    .box-title-1 {
      width: 100%;
      text-align: center;
      position: relative;

      .center {
        width: 100%;
        position: absolute;
        margin-top: -30px;

        p:nth-child(1) {
          font-size: 28px;
          font-weight: 600;
          color: #fc476d;
        }

        p:nth-child(2) {
          font-size: 12px;
          color: var(--colorTip);
        }
      }
    }

    .box-2-nav {
      width: 100%;
      margin-top: 100px;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;

      .box-item {
        margin-bottom: 25px;
        width: 278px;
        min-height: 480px;
        background: var(--itemBgk);
        //border-radius: 10px;
        overflow: hidden;
        padding: 10px;
        box-sizing: border-box;
        box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;

        .image {
          width: 100%;
          height: 250px;
          object-fit: cover;
        }

        .nav {
          width: 100%;
          margin-top: 15px;
          display: flex;
          justify-content: space-between;

          .left-icon {
            font-size: 14px;
            color: var(--navCircle);

            i {
              color: #fc476d;
            }
          }
        }

        .nav-content {
          font-size: 14px;
          margin-top: 10px;
          color: var(--colorTip);
        }

        .btn {
          width: 100%;
          height: 40px;
          display: flex;
          justify-content: center;
          margin-top: 18px;
          align-items: center;
          border: 1px solid var(--switchBorder);
          color: var(--activeColor);
        }
      }

      .box-item-length {
        width: 48%;
        margin: 10px 0;
        min-height: 150px;
        padding: 10px;
        background: var(--itemBgk);
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;

        .img-left {
          width: 220px;
          height: 220px;
          object-fit: cover;
        }

        .right-box {
          width: calc(100% - 220px);
          margin-left: 15px;
          padding-top: 15px;
          box-sizing: border-box;

          .titles {
            font-weight: 600;
            font-size: 18px;
            color: var(--navCircle);
          }

          .time {
            font-size: 16px;
            color: var(--navCircle);
            margin-top: 10px;
          }

          .btn-bot {
            margin-top: 20px;
            width: 200px;
            height: 42px;
            border-radius: 5px;
            background: var(--activeColor);
            color: var(--navBgk);
            font-size: 14px;
            display: flex;
            justify-content: center;
            align-items: center;
          }
        }
      }
    }
    .table{
      margin-top: 120px;
      margin-bottom: 20px;
    }
    .box-bottom {
      width: 100%;
      display: flex;
      //justify-content: center;
      margin-top: 30px;
    }
  }
}

::v-deep(.el-dialog){
  border-radius: 30px;
}
.avatar-uploader{
  width: 150px;
  height: 150px;
  //border-radius: 50%;
  display: flex;
  align-items: center;
  border: 1px dashed #d9d9d9;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 150px;
  height: 150px;
  line-height: 150px;
  text-align: center;
}
.avatars {
  width: 150px;
  height: 150px;
  display: block;
}
</style>
